import Vue from 'vue'
import axios from 'axios'

axios.defaults.baseURL = 'http://127.0.0.1:3000'
axios.interceptors.response.use(function (response) {
    return response.data
})
axios.interceptors.request.use(function (request) {
    var tokenString = localStorage.getItem("login_data") || '{}'
    var token = JSON.parse(tokenString).token

    if (token) {
        request.headers.Authorization = token
    }
    return request
})


Vue.prototype.$http = axios
Vue.prototype.static_host = "http://127.0.0.1:3000"
export default axios